package pool;


import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 索引文档
 * 注意:this中不要使用静态变量,
 * 该对象是可复用的,复用之后返回给对象池                       所有的对象会被刷新成null
 * 基本类型会被设置成                       0,                       StringBuilder会被清空
 *
 * @author c_jia
 */
public class IndexDoc {

  public int id;

  public int ID;

  public String code;

  public String word;

  public String eName;

  //                       不做任何处理的英文名，展示使用
  public String enName;

  public String type;

  public String url;

  public String urlTemplate;

  public double lat;

  public double lon;

  public double rankScore;

  public int cityId;

  public String cityName;

  public String cityEname;

  public int districtId;

  public String districtName;

  public String districtPinyin;

  public String cityCode;

  public int provinceId;

  public String provinceName;

  public int countryId;

  public String countryName;

  public String description;

  public long poiId;

  public String distance;

  public double distanceToLocation;

  public String price;

  public String priceTag;

  public String categoryIds;

  public String arrivalCityName;

  public String arrivalCity;

  public String departureCityName;

  public String departureCity;

  public String shortName;

  public String arrivalAirportName;

  public String arrivalAirport;

  public String arrivalName;

  public String arrivalTime;

  public String departureAirportName;

  public String departureAirport;

  public String departureName;

  public String departureTime;

  public String dataChangeCreateTime;

  public String arrivalAiportCode;

  public String departureAirportCode;

  public String districtPath;

  public double productScore;

  public StringBuilder scoreDesc = new StringBuilder(0);

  public double childProductScore;

  public StringBuilder childScoreDesc = new StringBuilder(0);

  public int simNum;

  public int otherMatchScore;

  public String channels;

  public String content;

  public String multiPrice;

  public String multiSales;

  public String source;

  public String pinyin;

  public String airportCode;

  public int index;

  //模式：添加、删除、修改
  public ConfigMode mode;

  public String urlInfo;

  public List<TagEntity> tagList;

  public List<TagEntity> childTagList;

  public List<IndexDoc> childProductList;

  public MoreEntity more;


  public String zoneName;

  public String locationName;

  public String numText;

  public int productNum;

  public double luceneScore;

  public int productScoreWthMatcher;

  public String startIds;

  public String destinationIds;

  public String alias;

  public String multiRank;

  public int star;

  public String starRating;

  public String starType;

  public int clickCount;

  public double clickScore;

  public String comment;

  public int commentCount;

  public float commentScore;

  public String commentlevel;

  public String commentlabel;

  public IndexDoc posDoc;

  public String multiKeyword;

  public String productName;

  public String firstStartIds;

  public int sales = 0;

  public int matchScore = 0;

  public String interline;

  public String imageUrl;

  public List<String> labelNames;

  public String labelName;

  public String tagNames;

  public String tagIds;

  public int sort = 0;

  public String visitCount;

  public String publishTime;

  public int localMonthPv;

  public int noLocalMonthPv;

  public int localWeekPv;

  public int noLocalWeekPv;

  public String brandName;

  public String groupName;

  public String advanceBookingDays;

  public String vendorName;

  public String workTime;

  public String yachtInfo;

  public boolean hasLounge;

  public int productFrom;

  public String query;

  public String features;

  public String shortFeature;

  public int startScore;

  public int topRank;

  public List<String> picTopLeftLabelNames;

  public String visaPolicyType;

  public List<HotelStoreInterestEntity> hotelstoreInterest;

  public String otherInfos;

  public String uid;

  public int buViewCount;

  public int buClickCount;

  public String districtType;

  public int parentDistrictId;

  public String parentDistrictName;

  public boolean hasPocketGs;

  public String weatherImage;

  public String weatherNo;

  public String address;

  public long infos;

  public List<String> images;

  public String firstTagNames;

  public String interTrainTab;

  public int traveldays;

  public String ranking;

  public Boolean hasVoiceGuide;

  public String authorInfo;

  //监控
  static AtomicInteger count = new AtomicInteger(0);

  public IndexDoc() {
    count.getAndIncrement();
  }

  public static IndexDoc newIndexDocForCache() {
    return new IndexDoc();
  }

  public void clear() {
    this.id = 0;
    this.ID = 0;
    this.code = null;
    this.word = null;
    this.eName = null;
    this.enName = null;
    this.type = null;
    this.url = null;
    this.urlTemplate = null;
    this.lat = 0;
    this.lon = 0;
    this.rankScore = 0;
    this.cityId = 0;
    this.cityName = null;
    this.cityEname = null;
    this.districtId = 0;
    this.districtName = null;
    this.districtPinyin = null;
    this.cityCode = null;
    this.provinceId = 0;
    this.provinceName = null;
    this.countryId = 0;
    this.countryName = null;
    this.description = null;
    this.poiId = 0;
    this.distance = null;
    this.distanceToLocation = 0;
    this.price = null;
    this.priceTag = null;
    this.categoryIds = null;
    this.arrivalCityName = null;
    this.arrivalCity = null;
    this.departureCityName = null;
    this.departureCity = null;
    this.shortName = null;
    this.arrivalAirportName = null;
    this.arrivalAirport = null;
    this.arrivalName = null;
    this.arrivalTime = null;
    this.departureAirportName = null;
    this.departureAirport = null;
    this.departureName = null;
    this.departureTime = null;
    this.dataChangeCreateTime = null;
    this.arrivalAiportCode = null;
    this.departureAirportCode = null;
    this.districtPath = null;
    this.productScore = 0;
    this.scoreDesc.setLength(0);
    this.childProductScore = 0;
    this.childScoreDesc.setLength(0);
    this.simNum = 0;
    this.otherMatchScore = 0;
    this.channels = null;
    this.content = null;
    this.multiPrice = null;
    this.multiSales = null;
    this.source = null;
    this.pinyin = null;
    this.airportCode = null;
    this.index = 0;
    this.mode = null;
    this.urlInfo = null;
    this.tagList = null;
    this.childTagList = null;
    this.childProductList = null;
    this.more = null;
    this.zoneName = null;
    this.locationName = null;
    this.numText = null;
    this.productNum = 0;
    this.luceneScore = 0;
    this.productScoreWthMatcher = 0;
    this.startIds = null;
    this.destinationIds = null;
    this.alias = null;
    this.multiRank = null;
    this.star = 0;
    this.starRating = null;
    this.starType = null;
    this.clickCount = 0;
    this.clickScore = 0;
    this.comment = null;
    this.commentCount = 0;
    this.commentScore = 0;
    this.commentlevel = null;
    this.commentlabel = null;
    this.posDoc = null;
    this.multiKeyword = null;
    this.productName = null;
    this.firstStartIds = null;
    this.sales = 0;
    this.matchScore = 0;
    this.interline = null;
    this.imageUrl = null;
    this.labelNames = null;
    this.labelName = null;
    this.tagNames = null;
    this.tagIds = null;
    this.sort = 0;
    this.visitCount = null;
    this.publishTime = null;
    this.localMonthPv = 0;
    this.noLocalMonthPv = 0;
    this.localWeekPv = 0;
    this.noLocalWeekPv = 0;
    this.brandName = null;
    this.groupName = null;
    this.advanceBookingDays = null;
    this.vendorName = null;
    this.workTime = null;
    this.yachtInfo = null;
    this.hasLounge = false;
    this.productFrom = 0;
    this.query = null;
    this.features = null;
    this.shortFeature = null;
    this.startScore = 0;
    this.topRank = 0;
    this.picTopLeftLabelNames = null;
    this.visaPolicyType = null;
    this.hotelstoreInterest = null;
    this.otherInfos = null;
    this.uid = null;
    this.buViewCount = 0;
    this.buClickCount = 0;
    this.districtType = null;
    this.parentDistrictId = 0;
    this.parentDistrictName = null;
    this.hasPocketGs = false;
    this.weatherImage = null;
    this.weatherNo = null;
    this.address = null;
    this.infos = 0;
    this.images = null;
    this.firstTagNames = null;
    this.interTrainTab = null;
    this.traveldays = 0;
    this.ranking = null;
    this.hasVoiceGuide = null;
    this.authorInfo = null;

  }

  public static void main(String[] args) throws IllegalAccessException {
    IndexDoc indexDoc = new IndexDoc();
    Class<IndexDoc> indexDocClass = IndexDoc.class;
    Field[] declaredFields = indexDocClass.getDeclaredFields();
    for (int i = 0; i < declaredFields.length; i++) {
      Field declaredField = declaredFields[i];
      Type genericType = declaredField.getGenericType();

      System.out.print("\n this." + declaredField.getName() + "= ");
      switch (genericType.getTypeName()) {
        case "byte":
          declaredField.setByte(indexDoc, (byte) 0);
          System.out.print(0);
          break;
        case "char":
          declaredField.setChar(indexDoc, (char) 0);
          System.out.print(0);
          break;
        case "short":
          declaredField.setShort(indexDoc, (short) 0);
          System.out.print(0);
          break;
        case "int":
          declaredField.setInt(indexDoc, 0);
          System.out.print(0);
          break;
        case "long":
          declaredField.setLong(indexDoc, 0);
          System.out.print(0);
          break;
        case "double":
          declaredField.setDouble(indexDoc, 0);
          System.out.print(0);
          break;
        case "float":
          declaredField.setFloat(indexDoc, 0);
          System.out.print(0);
          break;
        case "boolean":
          declaredField.setBoolean(indexDoc, false);
          System.out.print("false");
          break;
        case "java.lang.StringBuilder":
          Object o1 = declaredField.get(indexDoc);
          if (o1 != null) {
            StringBuilder o = (StringBuilder) o1;
            o.setLength(0);
          }
          System.out.print("setLength(0)");
          break;
        default:
          declaredField.set(indexDoc, null);
          System.out.print("null");
          break;
      }
      System.out.print(";");
    }
  }

}
